#Region " Imports "

Imports System.Data
Imports BlazeApps.Library.Tags

#End Region

Partial Class Usercontrols_Tags_TagsList
    Inherits UserControlBase

#Region " Enums, Memebers and Properties "

#End Region

#Region " Page Events "

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Me.Page.IsPostBack = False Then
            BindDataItems()
        End If

    End Sub

#End Region

#Region " Save Data "



#End Region

#Region " Load Data "

    Public Overloads Overrides Sub BindDataItems()

        Dim List As New TagList

        With Me.uxTagsRepeater
            .DataSource = List.GetTagsList()
            .DataBind()
        End With

    End Sub

#End Region

#Region " Form Controls Events "

    Protected Sub uxTagsRepeater_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles uxTagsRepeater.ItemDataBound
        Dim HL As HyperLink = e.Item.FindControl("uxTagHyperLink")

        If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then

            HL.Style("font-size") = GetFontSize(CType(e.Item.DataItem("tagcount"), Integer))

        End If

    End Sub

#End Region

#Region " Helpers and Methods "

    Private Function GetFontSize(ByVal TagCount As Integer) As String

        Dim FontScale() As String = {"x-small", "small", "medium", "large", "x-large", "xx-large"}

        Select Case TagCount
            Case 1, 2, 3
                Return FontScale(0)
            Case 4, 5, 6, 7, 8, 9, 10
                Return FontScale(1)
            Case 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
                Return FontScale(2)
            Case 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
                Return FontScale(3)
            Case 31, 32, 33, 34, 35, 36, 37, 38, 39, 40
                Return FontScale(4)
            Case Else
                Return FontScale(5)
        End Select
    End Function

#End Region

End Class
